#include "LiveSevice.h"
#include "../CinUserMap.h"
#include "../utils/Utils.h"


LiveSevice::LiveSevice(/* args */)
{
}

LiveSevice::~LiveSevice()
{
}

 void LiveSevice::doHandle(const char *pDataBuffer)
 {
    NetPacket_TimeLive *pData = (NetPacket_TimeLive *)pDataBuffer;

    long old_time = CinUserMap::GetInstance()->findFdTime(peerfd);
    long cur_time = Utils::getCurTime();

    cout<< "old_time="<< old_time << "  cur_time=" << cur_time <<endl;
    long rt = cur_time - old_time;
    CinUserMap::GetInstance()->updateClients(peerfd, cur_time);//更新时间值
   
    NetPacket_TimeLive vData;   
    vData.curtime = cur_time;
    strncpy(vData.uid, pData->uid, sizeof(vData.uid));    
   
    mSocket->send(peerfd, NET_TIMELIVE, (const char*)&vData, sizeof(vData));     

   // free(pDataBuffer);     

 }